package com.ihd.ihardware.view.tzc.discovery.viewmodel;

import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.support.annotation.NonNull;

import com.ihd.ihardware.view.tzc.discovery.model.DiscoveryRepository;

public class WebViewModel extends AndroidViewModel {

    private DiscoveryRepository mDiscoveryRepository;

    public WebViewModel(@NonNull Application application) {
        super(application);
    }

    public void sendArtComment(String id, String content) {
        if (mDiscoveryRepository == null)
            mDiscoveryRepository = new DiscoveryRepository();
        mDiscoveryRepository.sendArtComment(id, content);
    }

    public void artCollect(String id) {
        if (mDiscoveryRepository == null)
            mDiscoveryRepository = new DiscoveryRepository();
        mDiscoveryRepository.artCollect(id);
    }

    public void collectCancel(String id) {
        if (mDiscoveryRepository == null)
            mDiscoveryRepository = new DiscoveryRepository();
        mDiscoveryRepository.collectCancel(id);
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        if (null != mDiscoveryRepository) {
            mDiscoveryRepository.onDestroy();
            mDiscoveryRepository = null;
        }
    }
}
